unit NameEditorFrm;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons, ExtCtrls;

type
  TNameEditorForm = class(TForm)
    leName: TLabeledEdit;
    bOK: TBitBtn;
    Label1: TLabel;
    procedure leNameKeyPress(Sender: TObject; var Key: Char);
    procedure FormKeyPress(Sender: TObject; var Key: Char);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

Const
 EnterKey = #13;
 ESC_KEYCODE = #27;

var
  NameEditorForm: TNameEditorForm;

implementation

{$R *.dfm}

procedure TNameEditorForm.leNameKeyPress(Sender: TObject; var Key: Char);
begin
 if (key = EnterKey) then ModalResult := mrOK;
end;

procedure TNameEditorForm.FormKeyPress(Sender: TObject; var Key: Char);
begin
 if Key = ESC_KEYCODE then ModalResult := mrOk;
end;

end.
